package main

import "C"
import (
	"fmt"
	"io/ioutil"
	"net/http"
)

//export add
func add(x, y int) int {
	return x + y
}

//export remove_int
func remove_int(x, y int) int {
	return x - y
}

//export request_baidu
func request_baidu() *C.char {
	var seed chan string = make(chan string)

	// resp := getData(seed)

	// return C.CString(resp)

	go getData(seed)

	select {
	case ch1 := <-seed:
		fmt.Println("abc", ch1)
		return C.CString(ch1)
	}
}

func getData(seed chan string) {
	res, _ := http.Get("https://www.baidu.com")
	defer res.Body.Close()
	resp, _ := ioutil.ReadAll(res.Body)
	seed <- string(resp)
}

func main() {
}
